import 'package:freezed_annotation/freezed_annotation.dart';
import 'dart:convert';

part 'user_mobilelogin_response.freezed.dart';
part 'user_mobilelogin_response.g.dart';

@freezed
class UserMobileloginResponse with _$UserMobileloginResponse {
  const factory UserMobileloginResponse({
    @JsonKey(name: "code") required int code,
    @JsonKey(name: "msg") required String msg,
    @JsonKey(name: "time") required String time,
    @JsonKey(name: "data") required Data? data,
  }) = _UserMobileloginResponse;

  factory UserMobileloginResponse.fromJson(Map<String, dynamic> json) =>
      _$UserMobileloginResponseFromJson(json);
}

@freezed
class Data with _$Data {
  const factory Data({
    @JsonKey(name: "userinfo") required Userinfo userinfo,
  }) = _Data;

  factory Data.fromJson(Map<String, dynamic> json) => _$DataFromJson(json);
}

@freezed
class Userinfo with _$Userinfo {
  const factory Userinfo({
    @JsonKey(name: "id") required int id,
    @JsonKey(name: "username") required String username,
    @JsonKey(name: "nickname") required String nickname,
    @JsonKey(name: "mobile") required String mobile,
    @JsonKey(name: "avatar") required String avatar,
    @JsonKey(name: "score") required int score,
    @JsonKey(name: "token") required String token,
    @JsonKey(name: "user_id") required int userId,
    @JsonKey(name: "createtime") required int createtime,
    @JsonKey(name: "expiretime") required int expiretime,
    @JsonKey(name: "expires_in") required int expiresIn,
  }) = _Userinfo;

  factory Userinfo.fromJson(Map<String, dynamic> json) =>
      _$UserinfoFromJson(json);
}
